<?php
include "const.php";
if ($_POST) {
    //登录后
    include "./lib/function.php";
    if (encode($_POST['username']) == ADMIN_NAME && encode($_POST['password']) == ADMIN_PWD) {
        session_start(); //开启session
        $_SESSION['admin'] = array("admin_name" => ADMIN_NAME);
        header("location:index.php");
    } else {
        js_redirect("login.php", "登录失败");
    }
} else {
    //登录之前
    include "./tpl/login.html";
}
